var entityCollection = require('../../../Base/server/controllers/EntityCollection');

//根据用户记录获取角色信息集合
exports.getRolesByUser = function(userRecord, completeFun){
	var roleEntity = entityCollection.getEntity("Role");
	roleEntity.find({
		_id: {
            $in: userRecord.Roles
        }
	}, null, null, function(err, roleRecords){
		if(err){
			var newErr = new Error();
            newErr.leval = 9;
            newErr.title = '查询用户角色信息失败';
            newErr.message = '查询失败，请检查查询参数！';
            completeFun(newErr);
		}
		else{
			completeFun(null, roleRecords);
		}
	});
};